/*
* Copyright (C) 2024-2025 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "compixmap.h"
#include "common.h"
#include "gsettingkey.h"

#include <QFrame>
#include <QLineEdit>

#include <QPushButton>
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QHBoxLayout>

//#include <darrowrectangle.h>


class PasswordEdit;
class DBusInvokerInterface;
class SettingsInvokerInterface;

class PrivilegeSeparationDialog : public QFrame
{
    Q_OBJECT
public:
    explicit PrivilegeSeparationDialog(QWidget *parent = nullptr);

private:
    // 初始化界面
    void initUI();

    // 内容初始化
    QWidget *initContent();

    // 生成策略项
    QHBoxLayout *createPolicyItem(QWidget *leftWidget, QWidget *bottomWidget, QWidget *rightWidget);

    // 提示错误信息
    void showTipErrorInfo(PasswordEdit *edit, const QString &msg);

    // 得到当前输入密码等级
    int getCurrentPasswordLevel(const char *newPasswd);

    // 判断输入密码字符长度是否超出限制
    bool PasswordJudgmentLength(const QString &Passwd);

private Q_SLOTS:
    // 接受确认按钮槽
    void acceptConfirmButtonClicked();
    // 接受取消按钮槽
    void acceptCancelButtonClicked();

protected:
    void closeEvent(QCloseEvent *event) override;

Q_SIGNALS:
    // 弹框点击确定完成信号
    void notifyDialogFinish(const QString &sSysadmPassword, const QString &sSecadmPassword, const QString &sAudadmPassword);
    // 弹框点击确定完成信号
    void notifyDialogClose();

private:
//    DBlurEffectWidget *m_blurEffect; // 透明背景
//    DTitlebar *m_titleBar;
    PasswordEdit *m_sysadmPassword;
    PasswordEdit *m_sysadmPasswordRe;
    PasswordEdit *m_audadmPassword;
    PasswordEdit *m_audadmPasswordRe;
    PasswordEdit *m_secadmPassword;
    PasswordEdit *m_secadmPasswordRe;
    QPushButton *m_cancelBtn;
    QPushButton *m_oKBtn;
    bool m_isFinishFlag;

    SettingsInvokerInterface *m_gSettingsInvokerInter;
    DBusInvokerInterface *m_loginSafetySysInvokerInter;
};
